perm filename GFTODV.CH[MF,SYS]2 blob
sn#755866 filedate 1984-05-27 generic text, type C, neo UTF8
COMMENT ⊗ VALID 00009 PAGES
C REC PAGE DESCRIPTION
C00001 00001
C00002 00002 @x Tell WEAVE to print only the changes:
C00003 00003 @x terminal output
C00005 00004 @x opening binary files
C00007 00005 @x faster qi and qo
C00008 00006 @x Parsing file names:
C00014 00007 @x command line scanning
C00018 00008 @x The DVI output buffer:
C00020 00009 @x "r DVIdover":
C00023 ENDMK
C⊗;
@x Tell WEAVE to print only the changes:
\centerline{\hsize 5in\baselineskip9pt
\vbox{\ninerm\noindent
The preparation of this report
was supported in part by the National Science
Foundation under grants IST-8201926 and MCS-8300984,
and by the System Development Foundation. `\TeX' is a
trademark of the American Mathematical Society.}}}
@y
\centerline{(This listing shows the changes for {\sc WAITS} only)}}
\let\maybe=\iffalse
@z
@x terminal output
@d print(#)==write(#)
@d print_ln(#)==write_ln(#)
@d print_nl(#)==begin write_ln; write(#);
end
@p program GF_to_DVI(@!output);
@y
@d print(#)==write(tty,#)
@d print_ln(#)==write_ln(tty,#)
@d print_nl(#)==begin write_ln(tty); write(tty,#);
end
@p @{@&$D:5@} program GF_to_DVI;
@z that D:5 stuff can go, after this is debugged
@x
@d update_terminal == break(output) {empty the terminal output buffer}
@<Glob...@>=
@!buffer:array[0..terminal_line_length] of 0..255;
@!term_in:text_file; {the terminal, considered as an input file}
@y
@d update_terminal == break(tty) {empty the terminal output buffer}
@d term_in == tty {the terminal, considered as an input file}
@<Glob...@>=
@!buffer:array[0..terminal_line_length] of 0..255;
@z
@x opening binary files
@p procedure open_gf_file; {prepares to read packed bytes in |gf_file|}
begin reset(gf_file,name_of_file);
cur_loc←0;
end;
@#
procedure open_tfm_file; {prepares to read packed bytes in |tfm_file|}
begin reset(tfm_file,name_of_file);
end;
@#
procedure open_dvi_file; {prepares to write packed bytes in |dvi_file|}
begin rewrite(dvi_file,name_of_file);
end;
@y
@p procedure open_gf_file; {prepares to read packed bytes in |gf_file|}
begin reset(gf_file,name_of_file,'/B:8/O');
cur_loc←0;
end;
@#
procedure open_tfm_file; {prepares to read packed bytes in |tfm_file|}
begin reset(tfm_file,name_of_file,'/B:8');
end;
@#
procedure open_dvi_file; {prepares to write packed bytes in |dvi_file|}
begin rewrite(dvi_file,name_of_file);
end;
@z
@x faster qi and qo
@d qi(#)==#+min_quarterword
{to put an |eight_bits| item into a quarterword}
@d qo(#)==#-min_quarterword
{to take an |eight_bits| item out of a quarterword}
@y
@d qi(#)==# {to put an |eight_bits| item into a quarterword}
@d qo(#)==# {to take an |eight_bits| item out of a quarterword}
@z
@x Parsing file names:
@ The file names we shall deal with for illustrative purposes have the
following structure: If the name contains `\.>' or `\.:', the file area
consists of all characters up to and including the final such character;
otherwise the file area is null. If the remaining file name contains
`\..', the file extension consists of all such characters from the first
remaining `\..' to the end, otherwise the file extension is null.
@↑system dependencies@>
We can scan such file names easily by using two global variables that keep track
of the occurrences of area and extension delimiters:
@<Glob...@>=
@!area_delimiter:pool_pointer; {the most recent `\.>' or `\.:', if any}
@!ext_delimiter:pool_pointer; {the relevant `\..', if any}
@y
@ The file names we shall deal with have the following structure:
If the name contains `\.[', the file area consists of all characters
from this character to the end; otherwise the file area is null.
If the remaining file name contains `\..', the file extension consists of all
such characters from this character to the end, otherwise the file extension
is null. We can assume that there is at most one `\.[' and at most one `\..'.
@↑system dependencies@>
We can scan such file names easily by using two global variables that keep track
of the occurrences of area and extension delimiters:
@<Glob...@>=
@!area_delimiter:pool_pointer; {the most recent `\.[', if any}
@!ext_delimiter:pool_pointer; {the relevant `\..', if any}
@z
@x
to place. The program here sets it to `\.{TeXfonts:}'.
@↑system dependencies@>
@.TeXfonts@>
@<Initialize the strings@>=
l←9; init_str9("T")("e")("X")("f")("o")("n")("t")("s")(":")(home_font_area);@/
@y
to place. The program here sets it to `\.{[TEX,SYS]}'.
@↑system dependencies@>
@<Initialize the strings@>=
l←9; init_str9("[")("T")("E")("X")(",")("S")("Y")("S")("]")(home_font_area);@/
@z
@x
else begin if (c=">")∨(c=":") then
begin area_delimiter←pool_ptr; ext_delimiter←0;
end
else if (c=".")∧(ext_delimiter=0) then ext_delimiter←pool_ptr;
@y
else begin if c="[" then area_delimiter←pool_ptr
else if c="." then ext_delimiter←pool_ptr;
@z
@x
if area_delimiter=0 then cur_area←null_string
else begin cur_area←str_ptr; incr(str_ptr);
str_start[str_ptr]←area_delimiter+1;
end;
if ext_delimiter=0 then
begin cur_ext←null_string; cur_name←make_string;
end
else begin cur_name←str_ptr; incr(str_ptr);
str_start[str_ptr]←ext_delimiter; cur_ext←make_string;
end;
@y
cur_name←str_ptr;
if ext_delimiter=0 then cur_ext←null_string
else begin incr(str_ptr);
str_start[str_ptr]←ext_delimiter; cur_ext←str_ptr;
end;
if area_delimiter≤str_start[str_ptr] then
begin cur_area←null_string; incr(str_ptr); str_start[str_ptr]←pool_ptr;
end
else begin incr(str_ptr);
str_start[str_ptr]←area_delimiter; cur_area←make_string;
end;
@z
@x
for j←str_start[a] to str_start[a+1]-1 do append_to_name(str_pool[j]);
for j←str_start[n] to str_start[n+1]-1 do append_to_name(str_pool[j]);
for j←str_start[e] to str_start[e+1]-1 do append_to_name(str_pool[j]);
@y
for j←str_start[n] to str_start[n+1]-1 do append_to_name(str_pool[j]);
for j←str_start[e] to str_start[e+1]-1 do append_to_name(str_pool[j]);
for j←str_start[a] to str_start[a+1]-1 do append_to_name(str_pool[j]);
@z
@x command line scanning
Although this routine is system-independent, it should probably be
modified to take the file name from the command line (without an initial
prompt), on systems that permit such things.
@p procedure start_gf;
label found,done;
begin loop@+begin print_nl('GF file name: '); input_ln;
@.GF file name@>
buf_ptr←0; buffer[line_length]←"?";
while buffer[buf_ptr]=" " do incr(buf_ptr);
if buf_ptr<line_length then
begin @<Scan the file name in the buffer@>;
if cur_ext=null_string then cur_ext←gf_ext;
pack_file_name(cur_name,cur_area,cur_ext); open_gf_file;
if ¬ eof(gf_file) then goto found;
print_nl('Oops... I can''t find file '); print(name_of_file);
@.Oops...@>
@.I can't find...@>
end;
end;
found:job_name←cur_name; pack_file_name(job_name,null_string,dvi_ext);
open_dvi_file;
end;
@y
This routine has been modified to take the file name from the command line
(without an initial prompt).
@p function rescan:boolean; extern; @t\2@>@;
{puts the command line into the terminal buffer,
or returns |false| if there was no command line}
@#
procedure start_gf;
label found,done;
begin if rescan then
begin read_ln(tty); {get first character into |tty↑|}
while (¬ eoln(tty))∧(tty↑≠';') do get(tty);
if tty↑=';' then
begin get(tty); line_length←0;
while ¬ eoln(tty) do
begin buffer[line_length]←xord[tty↑]; incr(line_length); get(tty);
end;
end;
end
else line_length←0;
loop@+begin buf_ptr←0; buffer[line_length]←"?";
while buffer[buf_ptr]=" " do incr(buf_ptr);
if buf_ptr<line_length then
begin @<Scan the file name in the buffer@>;
if cur_ext=null_string then cur_ext←gf_ext;
pack_file_name(cur_name,cur_area,cur_ext); open_gf_file;
if ¬ eof(gf_file) then goto found;
print_nl('Oops... I can''t find file '); print(name_of_file);
@.Oops...@>
@.I can't find...@>
end;
print_nl('GF file name: '); input_ln;
@.GF file name@>
end;
found:job_name←cur_name; pack_file_name(job_name,null_string,dvi_ext);
open_dvi_file;
end;
@z
@x The DVI output buffer:
@!dvi_index=0..dvi_buf_size; {an index into the output buffer}
@y
@!dvi_index=0..dvi_buf_size; {an index into the output buffer}
@!packed_bytes=packed array[dvi_index] of eight_bits;
{buffer for \.{DVI} output}
@z
@x
@!dvi_buf:array[dvi_index] of eight_bits; {buffer for \.{DVI} output}
@y
@!dvi_buf:packed_bytes; {buffer for \.{DVI} output}
@z
@x
@p procedure write_dvi(@!a,@!b:dvi_index);
var k:dvi_index;
begin for k←a to b do write(dvi_file,dvi_buf[k]);
end;
@y
@p procedure ary_out(var f:file;@!b:packed_bytes; @!o,@!c:integer);
extern;@t\2@>@#
procedure write_dvi(@!a,@!b:dvi_index);
begin ary_out(dvi_file,dvi_buf,a div 4,(b+1-a)div 4);@{+1000@}
end;
@z
@x "r DVIdover":
goto final_end;
@y
@<Fill the line editor buffer with `\.{r DVIdover}'@>;
goto final_end;
@z
@x
@p begin initialize; {get all variables initialized}
@y
@p procedure ptwr1w(pty,c:integer); extern; @t\2@>@;
{simulates typing of a character on a \.{PTY}}
begin initialize; {get all variables initialized}
@z
@x
This section should be replaced, if necessary, by changes to the program
that are necessary to make \.{GFtoDVI} work at a particular installation.
It is usually best to design your change file so that all changes to
previous sections preserve the section numbering; then everybody's version
will be consistent with the printed program. More extensive changes,
which introduce new sections, can be inserted here; then only the index
itself will get a new section number.
@↑system dependencies@>
@y
Here are some things that are specific to {\mc WAITS}.
@↑system dependencies@>
@d pto_chr(#)==ptwr1w(0,ord(#)) {put a character in the line editor}
@d dover_typein=home_font_area+1
@d boise_typein=home_font_area+2
@<Initialize the strings@>=
l←11; init_str11("r")(" ")("D")("V")("I")("d")("o")("v")("e")("r")(";")
(dover_typein);
l←6; init_str6("b")("o")("i")("s")("e")(" ")(boise_typein)
@ @<Fill the line editor...@>=
write_ln(tty);
k←str_start[font_name[gray_font]];
if (str_pool[k]="g")∧(str_pool[k+1]="r")∧(str_pool[k+2]="b")∧@|
(str_pool[k+3]="o")∧(str_pool[k+4]="i")∧(str_pool[k+5]="s") then
for k←str_start[boise_typein] to str_start[boise_typein+1]-1 do
pto_chr(xchr[str_pool[k]])
else for k←str_start[dover_typein] to str_start[dover_typein+1]-1 do
pto_chr(xchr[str_pool[k]]);
for k←str_start[job_name] to str_start[job_name+1]-1 do
pto_chr(xchr[str_pool[k]]);
pto_chr(xchr["."]);
pto_chr(xchr["d"]);
pto_chr(xchr["v"]);
pto_chr(xchr["i"]);
@z